/*******************************************************************************

AgentGame 12.10.
Copyright Peter Eredics (BUTE-DMIS) 2010-2012.

Position.java - position class

 *******************************************************************************/
package simplelab;

/**
 * Class representing positions in the game.
 *
 * @author Peter Eredics
 */
public class Position {

    /** X coordinate on the grid.*/
    public int x;
    /** Y coordinate on the grid.*/
    public int y;

    /**
     * Constructor setting booth coordinates 
     * @param x		X coordinate on the grid
     * @param y		Y coordinate on the grid
     */
    public Position(int x, int y) {
        this.x = x;
        this.y = y;
    }

    /**
     * Copy constructor
     * @param p		Position to be copied.
     */
    public Position(Position p) {
        this.x = p.x;
        this.y = p.y;
    }

    public Position() {
        this.x = 0;
        this.y = 0;
    }

    /**
     * Check equality of the positions.
     * @param p		The other position to check against.
     * @return		Returns true if positions are the same.
     */
    public boolean equals(Position p) {
        return ((p.x == x) && (p.y == y));
    }

    public Position clone() {
        return new Position(x, y);
    }

    @Override
    public String toString() {
        return "Position{" + "x=" + x + ", y=" + y + '}';
    }

    /**
     * ha a két koordináta közül akár csak egyik kisebb mint maga az position, akkor igazzal tér vissza
     * tehát ha kint van a pályán akkor igaz
     * @param x
     * @param y
     * @return 
     */
    boolean isLessThan(int x, int y) {
        return (this.x >= x) || (this.y >= y);
    }
    boolean isMoreThan(int x, int y){
        return (this.x< x) || (this.y < y);
    }

    Position oneStepAhaed(int dir) {
        if(dir == 0){
            this.y--;
        }else if(dir == 1){
            this.x ++;
        }else if(dir == 2){
            this.y ++;
        }else {
            this.x --;
        }
        return this;
    }
}
